<?php


/**
 * 竞拍日志
 * Enter description here ...
 * @author Admin
 *
 */
class Auction_logModel extends CommonModel {
	
	/**
	 * 自动填充
	 * Enter description here ...
	 * @var unknown_type
	 */
	protected $_auto = array ( 
		array('ip','get_client_ip',1,'function') , 
		array('address','getlocaltion',1,'function') , 
		array('addtime','time',1,'function'), 
	);
	
	
	
	/**
	 * 获取竞拍统计数据
	 * Enter description here ...
	 * @param unknown_type $map
	 * @param unknown_type $limit
	 */
	public function getCountData($map,$limit){
		$data = $this->where($map)->field('*,sum(beat) as beatsum,sum(pointb) as pointbsum,max(addtime) as maxtime,count(id) as bout')->order('id desc')->group('aid')->limit($limit)->findAll();
		return $data;
	}
	
	
	
	/**
	 * 获取竞拍统计数量
	 * Enter description here ...
	 * @param unknown_type $map
	 * @param unknown_type $limit
	 */
	public function getCountCount($map,$limit){
		$data = $this->where($map)->field('count(1)')->order('id desc')->group('aid')->limit($limit)->findAll();
		return count($data);
	}
	
	
	
	/**
	 * 保存
	 * Enter description here ...
	 * @param unknown_type $data
	 */
	public function insert($data){
		$data = $this->create($data,1);
		if (empty($data) || $data == false){
			return false;
		}
		
		$info = $this->add($data);
		if ($info){
			return $info;
		}else {
			return false;
		}
	}
	
}
?>